#ifndef CONNECTIONHANDLER__
#define CONNECTIONHANDLER__

#include <iostream>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <sstream>
#include "Poco/Net/StreamSocket.h"
#include "Poco/Net/SocketStream.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/Exception.h"

using namespace std;

// The employee's connection handler. Can connect and disconnect from the server when necessary.
class ConnectionHandler {

public:
	Poco::Net::SocketAddress sa_;
	Poco::Net::StreamSocket sock_;
	Poco::Net::SocketStream stream_;
	const short port_;
	const string host_;

	// Class constructor. Receives the server name and port, and builds a stream socket and a socket stream accordingly.
	ConnectionHandler(string host, short port);

	// Class destructor. Closes the stream socket.
	virtual ~ConnectionHandler(void);

	// Connect to the remote machine
	// Returns false if it was unable to properly connect.
	bool connect();
};

#endif // CONNECTIONHANDLER
